<template>
  <div class="notice-list">
    <div class="title">活动须知</div>
    <div class="notice-item" v-for="(notice, index) in notices" :key="index">
      <div class="tag-box">
        <span class="icon">
          <img :src="notice.icon_url" alt="" />
        </span>
        <span class="tag">{{ notice.title }}</span>
      </div>
      <div class="item-desc">
        <span
          class="content"
          :class="{
            diamond: c.color == '#D94648',
            triangle: c.color == '#333333'
          }"
          v-for="(c, index) in formatContent(notice.content)"
          :key="index"
          >{{ c.text }}</span
        >
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    notices: Array
  },
  methods: {
    formatContent(content) {
      const contentList = []
      content.split('\n').forEach((item) => {
        let color = ''
        if (item[0] == '♦') {
          color = '#D94648'
        }
        if (item[0] == '▲') {
          color = '#333333'
        }
        contentList.push({
          color,
          text: item
        })
      })
      return contentList
    }
  }
}
</script>

<style lang="less" scoped>
.notice-list {
  padding: 0 10px 30px;
  background-color: #fff;
  margin-bottom: 15px;
  .title {
    padding: 10px 0;
    font-size: 18px;
    color: #4a4a4a;
    font-weight: 700;
    line-height: 34px;
  }

  .notice-item {
    padding: 0 10px;
    font-size: 12px;
    color: #555555;
    line-height: 18px;

    .tag-box {
      display: flex;
      padding: 10px 0;
      align-items: center;

      .icon {
        height: 16px;
        width: 16px;
        margin-right: 5px;

        img {
          height: 100%;
          width: 100%;
        }
      }
      .tag {
        font-size: 14px;
        color: #000;
        font-weight: 700;
      }
    }

    .item-desc {
      padding: 0 20px;
      display: flex;
      flex-direction: column;

      .content {
        padding-bottom: 5px;

        &.diamond::first-letter {
          transform: scaleX(1.2);
          margin-right: 2px;
          color: #d94648;
          font-size: 22px;
        }
        &.triangle::first-letter {
          color: #333333;
          font-size: 18px;
        }
      }
    }
  }
}
</style>
